<?php

namespace App\Repository\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Redis;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

/**
 * Class ItemsInformation.
 *
 * @package namespace App\Repository\Models;
 */
class ItemsInformation extends Model implements Transformable
{
    use TransformableTrait;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $table='items_information';
    protected $fillable = ['id','item_code','buyer_phone','buyer_contact','buyer_company','buyer_id','quote_contain','quote_trade_time','project_addr','seller_phone','seller_contact','seller_company','seller_id','sms_notify','goods_total','other_total','all_total','created_at','updated_at'];

    //配单状态
    const ITEM_STATUS_DELAY = 1; //已报价
    const ITEM_STATUS_PAY = 2; //待付款
    const ITEM_STATUS_CLOSE = 3; //已关闭
    const ITEM_STATUS_AFFIRM = 4; //完成

    public function items_products(){
        return $this->hasMany(ItemsProducts::class,'item_id','id');
    }

    public function sellerCompanyAddr(){
        return $this->hasOne(Company::class,'user_id','seller_id');
    }

    public function orders(){
        return $this->hasOne(Orders::class ,'order_code','item_code');
    }


}
